package infostroy.bookagolf.components.panels;

import infostroy.bookagolf.common.Constants.Colors;
import infostroy.bookagolf.common.Constants.Sizes;

import javax.swing.*;
import java.awt.*;

/**
 * Created by valer_000 on 2/15/14.
 */
public class GolfSlidePanel extends JPanel {

    private Dimension dimension;

    public GolfSlidePanel() {
        super();
        this.setBackground(Colors.GREEN);
    }

    public GolfSlidePanel(LayoutManager layout) {
        super(layout);
        this.setBackground(Colors.GREEN);
    }

    @Override
    public Dimension getPreferredSize() {
        if (dimension != null) {
            return dimension;
        } else {
            return new Dimension(Sizes.SLIDE_PANEL_MAX_WIDTH
                    , super.getPreferredSize().height);
        }
    }

    @Override
    public Dimension getMaximumSize() {
        if (dimension != null) {
            return dimension;
        } else {
            return new Dimension(Sizes.SLIDE_PANEL_MAX_WIDTH
                    , super.getMaximumSize().height);
        }
    }

    @Override
    public Dimension getMinimumSize() {
        if (dimension != null) {
            return dimension;
        } else {
            return new Dimension(Sizes.SLIDE_PANEL_MAX_WIDTH
                    , super.getMinimumSize().height);
        }
    }

    @Override
    public void setMaximumSize(Dimension maximumSize) {
       this.dimension = maximumSize;
    }
}
